home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -in_the_mag- / program_perfection / vbcc / mystartup / mystart.doc < prev    next >
Text File  |  2000-03-11  |  2KB  |  77 lines

  1. MyStartup
  2. =========
  3.  
  4. Fairly minimal startup code for the VBCC compiler which still
  5. supports some handy features.
  6.  
  7.  
  8. Function
  9. --------
  10.  
  11. This startup code sets up SYSBase, opens dos.library (no revision
  12. specified) and handles the WBStartup message. If dos.library
  13. cannot be opened, then the code will display a standard alert
  14. then exit, returning a fatal error.
  15.  
  16. The usual C entry point main is called with different parameters
  17. than usual. A prototype would be:
  18.  
  19. int main( char *command, int len );
  20.  
  21. command is a string containing just the arguments passed to your
  22. program NOT the whole command line. len is the length of the
  23. argument string. No parsing is performed on the argument string.
  24. In fact it is probably best to define your main() with no
  25. parameters, that is,
  26.  
  27. int main( void );
  28.  
  29. and use the dos.library ReadArgs() routine to parse any
  30. arguments.
  31.  
  32. The standard exit() function works as per normal. It's parameter is passed
  33. back to DOS as an return code (see dos.h). If you want to return an
  34. error code as well, use SetIoErr().
  35.  
  36. This startup code handles vlink constructors and destructor (auto
  37. initialization and exit functions) and so auto opening of
  38. libraries via auto.lib still works.
  39.  
  40. This startup code gets and replies to a Workbench startup
  41. message, so it safe to start your program from the WB. This
  42. message can be found in the global pointer WBenchMsg as per
  43. usual.
  44.  
  45. All C standard library functions will still work with the
  46. exception of the stdio routines. So, there's no fopen(), fread(),
  47. printf(), etc. Use dos.library equivalents instead.
  48.  
  49.  
  50. Rationale
  51. ---------
  52.  
  53. Why go to all this bother? Well, by cutting out the stdio stuff
  54. and the command line parsing, you can shave a couple of thousand
  55. bytes of your executable size. Not much in the big scheme of
  56. things, but what the hell. It's also more elegant when don't
  57. require portability. Why include all that stuff when you're just
  58. gonna use the dos.library calls anyway?
  59.  
  60. VBCC ships with a extrememly minimal startup module, but that
  61. doesn't support WB, constructors, destructors, etc. This one
  62. makes life easier . . .
  63.  
  64.  
  65. Linking
  66. -------
  67.  
  68. To use this startup code in your own projects, you must remember
  69. to disable the standard one with the -nostdlib switch. This has
  70. the unfortunate side effect of not using the standard linker
  71. libraries as well, so you'll have to include this manually.
  72. Always remember that mystartup.o MUST be the first file in your
  73. list of components.
  74.  
  75.  
  76.  
  77.